﻿using EnvDTE;

namespace MEFAddin.Adapters
{
    public class AddInAdapter : MEFAddin.Adapters.IAddInAdapter
    {
        private ILoggingAdapter _LoggingAdapter;

        private IWindowAdapter _WindowAdapter;

        private ICommandAdapter _CommandAdapter;

        private AddInContext _AddinContext;

        /// <summary>
        /// Gets the logging adapter.
        /// </summary>
        public ILoggingAdapter LoggingAdapter
        {
            get
            {
                return _LoggingAdapter;
            }
        }

        /// <summary>
        /// Gets the window adapter.
        /// </summary>
        public IWindowAdapter WindowAdapter
        {
            get
            {
                return _WindowAdapter;
            }

        }
        /// <summary>
        /// Gets the command adapter.
        /// </summary>
        public ICommandAdapter CommandAdapter
        {
            get
            {
                return _CommandAdapter;
            }
        }

        /// <summary>
        /// Gets the add in instance.
        /// </summary>
        public AddIn AddInInstance
        {
            get
            {
                return this._AddinContext.AddInInstance;
            }
        }

        /// <summary>
        /// Gets the documents.
        /// </summary>
        public Documents Documents
        {
            get
            {
                return this._AddinContext.AddInInstance.DTE.Documents;
            }
        }

        /// <summary>
        /// Gets the add in context.
        /// </summary>
        public AddInContext AddInContext
        {
            get
            {
                return _AddinContext;
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AddInAdapter"/> class.
        /// </summary>
        /// <param name="addinContext">The addin context.</param>
        /// <param name="loggingAdapter">The logging adapter.</param>
        /// <param name="windowAdapter">The window adapter.</param>
        /// <param name="commandAdapter">The command adapter.</param>
        public AddInAdapter(
            AddInContext addinContext,
            ILoggingAdapter loggingAdapter,
            IWindowAdapter windowAdapter,
            ICommandAdapter commandAdapter)
        {
            this._LoggingAdapter = loggingAdapter;
            this._WindowAdapter = windowAdapter;
            this._CommandAdapter = commandAdapter;
            this._AddinContext = addinContext;
        }
    }
}
